package com.qf.service.impl;

import com.qf.dao.CollectMapper;
import com.qf.pojo.entity.StoreCollect;
import com.qf.pojo.entity.StoreInfo;
import com.qf.pojo.entity.Users;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName CollectServiceImpl
 * @Description TODO
 * @Author 非乐
 * @Date 2022/9/28 20:44
 * @Version 1.0
 **/
@Service
public class CollectServiceImpl implements CollectService {

    @Autowired
    CollectMapper collectMapper;

    @Override
    public BaseResp addCollect(StoreCollect collect) {
        int i = collectMapper.addCollect(collect);
        if (i>0){
            return new BaseResp(200,"收藏成功",null);
        }
        else {
            return new BaseResp(0,"收藏失败",null);
        }
    }

    @Override
    public BaseResp delCollect(StoreCollect collect) {
        int i = collectMapper.delCollect(collect);
        if (i>0){
            return new BaseResp(200,"取消收藏",null);
        }
        else {
            return new BaseResp(0,"取消收藏失败",null);
        }
    }

    @Override
    public BaseResp favList(int userId) {
        List<StoreInfo> list = collectMapper.findStoreById(userId);
        return new BaseResp(200,"success",list);
    }
}
